/****************************************************
          File Name:mq_getattr.c
          Author: Abby Cin
          Mail: abbytsing@gmail.com
          Created Time: Sat 20 Sep 2014 09:46:30 AM CST
*****************************************************/

#include"posix_ipc.h"

int main(int argc,char *argv[])
{
    if(argc<2 || strcmp(argv[1],"--help")==0)
    {
        printf("%s mq\n",argv[0]);
        exit(EXIT_FAILURE);
    }

    mqd_t mq;
    struct mq_attr attr;

    if((mq=mq_open(argv[1],O_RDWR))==(mqd_t)-1)
        err("open");
    if(mq_getattr(mq,&attr)==-1)
        err("getattr");

    printf("mq_flags: %ld\nmq_maxmsg: %ld\n",attr.mq_flags,attr.mq_maxmsg);
    printf("mq_msgsize: %ld\nmq_curmsgs: %ld\n",attr.mq_msgsize,attr.mq_curmsgs);

    exit(EXIT_SUCCESS);
}
